let addZero = (num)=> {
    if(num < 10) return `0${num}`
    return num
}

let dateFormate = (timeI)=> {
    if(timeI) {
        var time = new Date(timeI)
    } else {
        var time = new Date()
    }
    // console.log(time)
    let year = time.getFullYear()
    let month = addZero(time.getMonth() + 1)
    let date = addZero(time.getDate())
    let hour = addZero(time.getHours())
    let min = addZero(time.getMinutes())
    let sec = addZero(time.getSeconds())
    let myTime = `${year}-${month}-${date} ${hour}:${min}:${sec}`
    // console.log(myTime)
    return myTime
}

// dateFormate()

module.exports=dateFormate
